#pragma once

#include <memory>
#include "instructions/base/instructions.h"
#include "rtda/frame.h"
#include "rtda/heap/class.h"

namespace jvm {
    namespace instructions {

        enum ArrayType {
            AT_BOOLEAN = 4,
            AT_CHAR = 5,
            AT_FLOAT = 6,
            AT_DOUBLE = 7,
            AT_BYTE = 8,
            AT_SHORT = 9,
            AT_INT = 10,
            AT_LONG = 11
        };

        class NEW_ARRAY : public Instruction {
        private:
            uint8_t _atype;
        public:
            void fetchOperands(std::shared_ptr<BytecodeReader> reader) override;
            void execute(std::shared_ptr<rtda::Frame> pframe) override;

        private:
            static std::shared_ptr<heap::Class> getPrimitiveArrayClass(std::shared_ptr<heap::ClassLoader> loader, uint8_t atype);

        };

    } // namespace instructions
}// namespace jvm